﻿namespace Leetcode.N0462;
public class Solution
{
    public int MinMoves2(int[] nums)
    {
        nums = nums.OrderBy(_ => _).ToArray();
        var ans = 0;
        var x = nums[nums.Length / 2];
        for (int i = 0; i < nums.Length; i++)
        {
            ans += Math.Abs(nums[i] - x);
        }
        return ans;
    }
}